#include <tenacitas.log/text_file.h>


// #############################################################################
// logger

// -----------------------------------------------------------------------------
void
tenacitas::log::text_file::
config( const std::string & p_pgm_name,
        std::int64_t p_pid,
        tenacitas::log::level p_level,
        uint64_t p_max_file_size,
        const std::string & p_dir_log ) {

    /** extracting pgm name out of full pgm name path */
    std::string l_full_pgm_name( p_pgm_name );

    std::string::size_type l_ind = l_full_pgm_name.rfind( '/' );
    if ( l_ind == std::string::npos ) {
        l_ind = l_full_pgm_name.rfind( '\\' );
    }

    std::string l_pgm_name;

    if ( l_ind == std::string::npos ) {
        l_pgm_name = l_full_pgm_name;
    }
    else {
        l_pgm_name = l_full_pgm_name.substr( l_ind + 1 );
    }

    /** configuring factories */
    change_file_handler::config( p_dir_log, l_pgm_name, p_pid );

    change_file_notifier::config( p_max_file_size );

    logger::set_level_all( p_level );
}




